import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import babel from 'vite-plugin-babel';

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        babel({
            babelConfig: {
                babelrc: false,
                configFile: false,
                plugins: [
                    ['@babel/plugin-proposal-decorators',{legacy:true},],
                    ["@babel/plugin-proposal-class-properties", { "loose" : true }],
                    // ["@babel/plugin-transform-class-properties", { "loose" : true }]
                ]
            }
        })],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        host: '0.0.0.0',
        proxy: {
            '/youdao': {
                target: 'https://dict.youdao.com',//替换的服务端地址
                changeOrigin: true,//开启代理，允许跨域
                rewrite: path => path.replace(/^\/youdao/, '')//设置重写的路径
            }
        }
    }
})
